﻿
@{
    ViewBag.Title = "BrrHistory";
    Layout = "~/Views/Shared/_LayoutForEUI.cshtml";
    var listColumns = ViewBag.Columns as List<SGArchiveSystem7x.Models.CColumnsModel>;
}

<table id="Insiders_BrrHistory_grid" class="easyui-datagrid" style="width:100%;" title="@ViewBag.NAME" data-options="
       rownumbers:true,
       singleSelect:true,
       autoRowHeight:false,
       pagination:true,
       fitColumns:false,
       fit:true,
       striped:true,
       checkOnSelect:false,
       selectOnCheck:false,
       toolbar:'#Insiders_BrrHistory_tb',
       collapsible:false,
       pageSize: @SGArchiveSystem7x.Models.CCommonsModels.PageSize,
       pageList:[10,15,20]">
    <thead frozen="true">
        <tr>
            @{foreach (var c in listColumns)
                {
                    if (c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
    <thead>
        <tr>
            @{foreach (var c in listColumns)
                {
                    if (!c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
</table>
<div id="Insiders_BrrHistory_tb" style="padding:2px 5px;">
    <input type="text" class="easyui-textbox" label="借阅人:" labelwidth="50px" labelalign="right" style="width:180px" id="Insiders_BrrHistory_txtName" />
    <input type="text" class="easyui-textbox" label="借阅档号:" labelwidth="70px" labelalign="right" style="width:180px" id="Insiders_BrrHistory_txtDH" />
    <input type="text" class="easyui-datebox" data-options="editable:false" label="借阅起始时间:" labelwidth="90px" labelalign="right" style="width:190px" id="Insiders_BrrHistory_txtSTime" />
    <input type="text" class="easyui-datebox" data-options="editable:false" label="借阅结束时间:" labelwidth="90px" labelalign="right" style="width:190px" id="Insiders_BrrHistory_txtETime" />
    <div style="display:none">
        <select id="Insiders_BrrHistory_cmbType" class="easyui-combobox" labelposition="right" label="借阅类型：" data-options="editable:false" name="Insiders_BrrHistory_cmbType" style="width:170px;" panelHeight="auto" editable="false">
            <option value="-1" selected="selected">全部</option>
            <option value="1">电子借阅</option>
            <option value="2">纸质借阅</option>
        </select>
    </div>
    <a href="javascript:void(0);" class="easyui-linkbutton button-blue" iconCls="icon-search" onclick="QUERY()" style="height: 30px;width:100px">查询</a>
   
</div>
<script>
    $(document).ready(function () {
        var type = $('#Insiders_BrrHistory_cmbType').combobox('getValue');
        $('#Insiders_BrrHistory_grid').datagrid({
            url: '/Insiders/Get_ajaxBrrHistoryArchive?brrstatus=' + '@ViewBag.BrrStatus' + '&type=' + type,
            singleSelect: true,
            method: 'post',
            onLoadSuccess: function (data) {
                $('.pagination-page-list').hide();
            }
        });
        InitPagenation();
    });
    

    function SearchPager(num, size) {

        $('#Insiders_BrrHistory_grid').datagrid('options').url = '/Insiders/Get_ajaxBrrHistoryArchivePager?num=' + num +
            '&size=' + size;
        $('#Insiders_BrrHistory_grid').datagrid('reload');
        $('#Insiders_BrrHistory_grid').datagrid('options').pageNumber = num;
        $('#Insiders_BrrHistory_grid').datagrid('options').pageSize = size;
    }


    ///初始化分页
    function InitPagenation() {
        //设置分页控件
        var p = $('#Insiders_BrrHistory_grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                SearchPager(pageNumber, pageSize);
            }
        });
    }
    function QUERY() {
        var name = $('#Insiders_BrrHistory_txtName').val();
        var dh = $('#Insiders_BrrHistory_txtDH').val();
        var type = $('#Insiders_BrrHistory_cmbType').combobox('getValue');
        var stime = $('#Insiders_BrrHistory_txtSTime').datebox('getValue');
        var etime = $('#Insiders_BrrHistory_txtETime').datebox('getValue');
        $('#Insiders_BrrHistory_grid').datagrid('options').url = '/Insiders/Get_ajaxBrrHistoryArchive?brrstatus=' + '@ViewBag.BrrStatus' + '&type=' + type + '&name=' + name + '&dh=' + dh + '&stime=' + stime + '&etime=' + etime;
        $('#Insiders_BrrHistory_grid').datagrid('load');
    }
    function formatDate(value, row) {
        if (value != null) {
            var time = new Date(parseInt(value.substr(6, 19)))//.toLocaleDateString();//13
            var month = (time.getMonth() + 1);
            if (month < 9)
                month = "0" + month;
            var day = time.getDate();
            if (day < 9)
                day = "0" + day;

            var hm = ''; 
            var hours = time.getHours(); var mint = time.getMinutes();
            if (hours == 0 && mint == 0)
                hm = '';
            else {
                if (hours < 9)
                    hours = "0" + hours;
                if (mint < 9)
                    mint = "0" + mint;

                hm = hours + ":" + mint;
            }
            

            return time.getFullYear() + "-" + month + "-" + day + " " + hm; ///+ ":" + time.getSeconds();
        }
        else {
            return "";
        }
    }
    function formatStatus(value, row) {
        if (value == 0) {
            return "申请";
        }
        else if (value == 1) {
            return "借出";
        }
        else {
            return "结束";
        }
    }
    function formatSPValue(value, row) {
        if (value == 0) {
            return "未审批";
        }
        else if (value == 1) {
            return "通过";
        }
        else {
            return "拒绝";
        }
    }
    function formatType(value, row) {
        if (value == 1) {
            return "电子借阅";
        }
        else {
            return "纸质借阅";
        }
    }
    function formatYQTS(value, row) {
        if (value == 0) {
            return "";
        }
        else {
            return value;
        }
    }
    function Download() {
        var grid = $('#Insiders_BrrHistory_grid');
        var options = grid.datagrid('getPager').data("pagination").options;
        var total = options.total;
        $.messager.confirm('提示', '确定是否导出？', function (r) {
            if (r) {
                if (total > 100) {
                    if (window.confirm('数据量过多，是否仍然需要导出？')) {
                        $.ajax({
                            url: '/Insiders/DownLoadxls',
                            dataType: "text",
                            type: "post",
                            success: function (data) {
                                window.open(data);
                            }
                        });
                    }
                }
                else {
                    $.ajax({
                        url: '/Insiders/DownLoadxls?',
                        dataType: "text",
                        type: "post",
                        success: function (data) {
                            //alert('下载');
                            window.open(data);
                        }
                    });
                }
            }
        })
    }
    function JYSP(id)
    {
        $.messager.confirm('提示', '确定是否导出？', function (r) {
            if (r) {
                $.ajax({
                    url: '/Insiders/brrtablexls?',
                    dataType: "text",
                    type: "post",
                    data: { id: id },
                    success: function (data) {
                        //alert('下载');
                        window.open(data);
                    }
                });
            }
        })
    }
    function formatJYSP(value, row)
    {
        var id = row.BI_ID;
        return "<a href='javascript:void(0)' onclick='JYSP("+id+")'><img src='../Content/images/images.png'></img></a>";
    }
    function formatSPStatus(value, row) {
        if (value == 0) {
            return "未审批";
        }
        else if (value == 1) {
            return "已审批";
        }
        else if (value == 2) {
            return "流程中(本部门审批)";
        }
        else {
            return "流程中(归档部门审批)";
        }
    }
    function InitPagenation() {
        //设置分页控件
        var p = $('#Insiders_BrrHistory_grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                QueryPager(pageNumber, pageSize);
            }
        });
    }
    ///分页查询
    function QueryPager(num, size) {
        $('#Insiders_BrrHistory_grid').datagrid('options').url = '/Insiders/Get_ajaxBrrHistoryArchivePager?num=' + num + '&size=' + size;
        $('#Insiders_BrrHistory_grid').datagrid('reload');
        $('#Insiders_BrrHistory_grid').datagrid('options').pageNumber = num;
        $('#Insiders_BrrHistory_grid').datagrid('options').pageSize = size;
        return;
    }
</script>


